﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MBS.UserControls.ScreenUserControl
{
    public partial class AddScreenUserControl : System.Web.UI.UserControl
    {

        MBSBLC.BLC screenblc = new MBSBLC.BLC();
        
        
        private bool actionresult;

        public bool Actionresult
        {
            get { return actionresult; }
             set { actionresult = value; }
        }


        public delegate void ScreenAddHandler();

        public event ScreenAddHandler ScreenAddComplete;
        public event ScreenAddHandler ScreenAddFailed;
        public static int cinemaID;



       
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                screenblc = new MBSBLC.BLC();
                CinemaList1.LoadDropDownBox();
            }
            AddScreenUserControl.cinemaID = CinemaList1.GetSelectedValue();
            CinemaList1.CimeListChanged += new CinemaUserControl.CinemaList.CinemaListHandler(CinemaList1_CimeListChanged);
        }

        void CinemaList1_CimeListChanged(int SelectedValue)
        {
            AddScreenUserControl.cinemaID = SelectedValue;
        }
                          
        protected void Button1_Click(object sender, EventArgs e)
        {

            actionresult = screenblc.AddScreen(cinemaID, TextBox1.Text.ToString(), TextBox3.Text.ToString());
           
            if (actionresult) 
            {
                ClearTextBoxes();
                ScreenAddComplete(); 
            }
            else
            {
                ScreenAddFailed();
            }
        
       
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            ClearTextBoxes();
         
        }

        private void ClearTextBoxes()
        {
            TextBox1.Text = "";
        }

    }
}